import React from 'react';
import { connect } from 'umi';
import { Login, Register } from './components';
import styles from './style.less';

const Auth = (props) => {
    const { type } = props.match.params;

    const authConfig = {
        login: {
            title: '登录',
            content: () => <Login />
        },
        register: {
            title: '注册',
            content: () => <Register />
        }
    };
    const authData = authConfig[type];
    if (!authData) return <div>页面找不到！！！</div>

    return <div className={styles.auth}>
        <div className={styles.header}>Aminer</div>
        <div className={styles.container}>
            <div className={styles.title}>{authData.title}</div>
            {authData.content()}
        </div>
    </div>
};

export default connect(({ auth }) => ({
    auth,
}))(Auth);